package com.lpb.spring.lpbspring.ioc;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;

/**
 * @ClassName GenericBeanDefinition
 * @Description 通用的bean定义对象实现
 * @date 2022/11/22 17:36
 * @Version 1.0
 * @authoe linpengbo
 */
public class GenericBeanDefinition implements BeanDefinition{

    private Class<?> beanClass;

    private String scope=scope_singletion;

    private String factoryBeanName;

    private String factoryMethodName;

    private String initMethodName;

    private boolean primary;

    List<?> constructorArgumentValues;

    Constructor<?> constructor;

    Method method;


    List<PropertyValue> propertyValues;

    public void setPrimary(boolean primary) {
        this.primary = primary;
    }

    public void setBeanClass(Class<?> beanClass) {
        this.beanClass = beanClass;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public void setFactoryBeanName(String factoryBeanName) {
        this.factoryBeanName = factoryBeanName;
    }

    public void setFactoryMethodName(String factoryMethodName) {
        this.factoryMethodName = factoryMethodName;
    }

    public void setInitMethodName(String initMethodName) {
        this.initMethodName = initMethodName;
    }

    public void setConstructorArgumentValues(List<?> constructorArgumentValues) {
        this.constructorArgumentValues = constructorArgumentValues;
    }

    public void setPropertyValues(List<PropertyValue> propertyValues) {
        this.propertyValues = propertyValues;
    }

    @Override
    public void setConstructor(Constructor<?> constructor) {
        this.constructor = constructor;
    }

    @Override
    public void setFactoryMethod(Method method) {
        this.method=method;
    }

    @Override
    public Method getFactoryMethod() {
        return this.method;
    }

    @Override
    public List<PropertyValue> getPropertyValues() {
        return this.propertyValues;
    }

    @Override
    public Class<?> getBeanClass() {
        return this.beanClass;
    }

    @Override
    public String getScope() {
        return this.scope;
    }

    @Override
    public String getFactoryBeanName() {
        return this.factoryBeanName;
    }

    @Override
    public String getFactoryMethodName() {
        return this.factoryMethodName;
    }

    @Override
    public String getInitMethodName() {
        return this.initMethodName;
    }

    @Override
    public List<?> getConstructorArgumentValues() {
        return  this.constructorArgumentValues;
    }

    @Override
    public Constructor<?> getConstructor() {
        return this.constructor;
    }

    @Override
    public boolean isSingleton() {
        return scope_singletion.equals(this.getScope());
    }

    @Override
    public boolean isPrototype() {
        return scope_prototype.equals(this.getScope());
    }

    @Override
    public boolean isPrimary() {
        return this.primary;
    }
}
